package com.example.administrator.exkotlin

import android.content.Intent
import android.os.Bundle
import com.example.administrator.exkotlin.activity.BaseActivity
import com.example.administrator.exkotlin.activity.Test_Activity_1
import com.example.administrator.exkotlin.activity.LifeActivity
import com.example.administrator.exkotlin.base.Generic
import com.example.administrator.exkotlin.base.`object`.*
import com.example.administrator.exkotlin.base.test
import com.example.administrator.exkotlin.broadcast.BroadCastActivity
import com.example.administrator.exkotlin.contentprovider.ContentActivity
import com.example.administrator.exkotlin.coroutine.CoroutineActivity
import com.example.administrator.exkotlin.endurance.EnduranceActivity
import com.example.administrator.exkotlin.jetpack.JetPackActivity
import com.example.administrator.exkotlin.multimedia.MeiaActivity
import com.example.administrator.exkotlin.multithread.MultithreadActivity
import com.example.administrator.exkotlin.net.NetActivity
import com.example.administrator.exkotlin.ui.NormalUiActivity
import com.example.administrator.exkotlin.ui.fragment.FragmentActivity
import com.example.administrator.exkotlin.ui.fragment.news.NewsActivity
import com.example.administrator.exkotlin.ui.list.ChatActivity
import com.example.administrator.exkotlin.ui.list.ListViewActivity
import com.example.administrator.exkotlin.ui.list.RecycleActivity

import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : BaseActivity() {
    private val TAG = "MainActivity"
    var a: Int = 10
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        println("Hello Kotlin!")

        //Test_Activity_1::class.java 相当于java中 Test_Activity_1.class
        btn_in.setOnClickListener { startActivity(Intent(this, Test_Activity_1::class.java)) }
        btn_life.setOnClickListener { startActivity(Intent(this, LifeActivity::class.java)) }
        btn_ui.setOnClickListener { startActivity(Intent(this, NormalUiActivity::class.java)) }
        btn_list.setOnClickListener { startActivity(Intent(this, ListViewActivity::class.java)) }
        btn_recycle.setOnClickListener { startActivity(Intent(this, RecycleActivity::class.java)) }
        btn_chat_demo.setOnClickListener { startActivity(Intent(this, ChatActivity::class.java)) }
        btn_fragment.setOnClickListener { startActivity(Intent(this, FragmentActivity::class.java)) }
        btn_news.setOnClickListener { startActivity(Intent(this, NewsActivity::class.java)) }
        btn_brocast.setOnClickListener { startActivity(Intent(this, BroadCastActivity::class.java)) }
        btn_endurance.setOnClickListener { startActivity(Intent(this, EnduranceActivity::class.java)) }
        btn_content.setOnClickListener { startActivity(Intent(this, ContentActivity::class.java)) }
        btn_media.setOnClickListener { startActivity(Intent(this, MeiaActivity::class.java)) }
        btn_thread.setOnClickListener { doTest() }
        btn_net.setOnClickListener { startActivity(Intent(this, NetActivity::class.java)) }
        btn_jetpack.setOnClickListener { startActivity(Intent(this, JetPackActivity::class.java)) }
        btn_Coroutine.setOnClickListener { startActivity(Intent(this, CoroutineActivity::class.java)) }
//        test()
//        println("asdas45465".letterCout())
//        println("扩展函数 + 运算符的重载 "+"asdas45465"*3)
//        println("重载 + "+(Money(1)+Money(2)).value)
//        BaseKotlin.static_kotin()
//        Log.d(TAG, "Max函数_1_内置max" +  BaseKotlin().add())
//        Log.d(TAG, "Max函数_1_内置max" +  BaseKotlin().largerNumberEx1(add(1, 99), 101))
//        Log.d(TAG, "Max函数_2_自定义max" + BaseKotlin().largerNumberEx2(add(1, 99), 102))
//        Log.d(TAG, "Max函数_3_if结果直接返回max" + BaseKotlin().largerNumberEx3(add(1, 99), 103))
//        Log.d(TAG, "Max函数_4_精简到一行if取掉括号" + BaseKotlin().largerNumberEx4(add(1, 99), 103))
//
//        Log.d(TAG,"when自定义"+BaseKotlin().getScore2("Tom"))
//        Log.d(TAG,"when自定义"+BaseKotlin().getScore2("jerry"))
//        Log.d(TAG,"when自定义"+BaseKotlin().getScore2("bob"))


        //不需要new，直接调用构造函数即可实例化Kotlin对象
//        Log.d(TAG,"判断类型"+ BaseKotlin().checkNumber(10))

//        Log.d(TAG,"forIn"+BaseKotlin().forIn3(20,10))

//        val student = Student(100, "男生","Tom",16)
//        student.play("game")
//        doStudy(student,"历史","语文")
//        student.toString()

//        val personDb = PersonDb("Tom", "male")
//
//        var type1 = DataHanlder.getDataType(personDb)
//        var type2 = DataHanlder.getDataType(Animal("Dog"))
//        var type3: DataHanlder.DataType = DataHanlder.getDataType(Person("Tom", 10))
//        Log.i(TAG, "类型1 " + type1)
//        Log.i(TAG, "类型2 " + type2)
//        Log.i(TAG, "类型3 " + type3)
//       DataHanlder.study(object :IStudy{
//override fun write(homeWorks: String?) {
//    TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
//}
//
//        override fun read(books: String?) {
//            TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
//        }
//    })
//        Collect().testList()
//        Collect().testSet()
//        Collect().testMap()
//        Collect().normal_collet()


//        println(LambdaEx.Exlambda_all())
//        LambdaEx.Exlambda_java_Thread_1()

//        val button: Button = Button(this)
//        button.setOnClickListener(object : View.OnClickListener {
//            override fun onClick(v: View?) {
//
//            }
//
//        })

//        val student = Student(name = "测试")

    }

    //面向接口，多态
    fun doStudy(study: IStudy, books: String, works: String) {
        study.read(books)
        study.write(works)
    }

    /**
     * 测试
     * */
    private fun doTest() {
        Generic.startActivity<MultithreadActivity>(this){
            putExtra("test","泛型实化")
        }
    }


}
